package com.qf.controller;

import com.qf.pojo.BaseResult;
import com.qf.pojo.TbUser;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by 54110 on 2021/4/30.
 */
@RestController
@RequestMapping("/user")
public class UserController {


    @Autowired
    UserService userService;
    /**
     * 验证用户 的用户名是否重复
     * @param map
     * @return
     */

    @RequestMapping("/validaUserName")
    public BaseResult validaUserName(@RequestBody Map map){
        return userService.validaUserName((String)map.get("userName"));
    }

    /**
     * 验证邮箱是否 重复
     * @param map
     * @return
     */
    @RequestMapping("/validaEmail")
    public BaseResult validaEmail(@RequestBody Map map){
        return userService.validaEmail((String)map.get("email"));
    }

    /**
     * 发送邮件
     * @param map
     * @return
     */
    @RequestMapping("/sendMail")
    public BaseResult sendMail(@RequestBody Map map){
        return userService.sendMail(map.get("email"));
    }

    /**
     * 注册
     */
    @RequestMapping("/registry")
    public BaseResult registry(@RequestBody TbUser tbUser){
        return userService.registry(tbUser);
    }

    @RequestMapping("/login")
    public BaseResult login(@RequestBody TbUser tbUser){
        return userService.login(tbUser);
    }
}
